<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/** 
* Menu Class 
* 
* Class to determine menu, such as when member login disable login and 
* register button
*
* @category	Libraries
* @subpackage Custom Libraries
* @author Ari Oaks
*/

class Mymenu{

	var $CI;
	var $menus;
	//var $menus['menu_main'] = array();
	
	function Mymenu()
	{
		$this->CI =& get_instance();
	}
	
	function menu_top()
	{
		$segment = $this->CI->uri->segment(1, 0);
		
		$menus = $this->CI->Menu_model->get_menus(1)->result_array();
		$menu = 	'<ul class="none-list-inline menu">';
		$num = 2;
		foreach($menus as $item):
			
			if($item['id']==9):
				$slug = '';
			else:
				$slug = $item['slug'];
			endif;
			
				if($item['id']==9):
					$active = (!$segment) ? ' active' : '';
					$menu .= 	'<li class="st'.$num.$active.'"><a href="'.site_url($slug).'">'.strtoupper($item['title']).'</a></li>';
				else:
					$active = ($segment && $segment==$item['slug']) ? ' active' : '';
					$menu .= 	'<li class="st'.$num.$active.'"><a href="'.site_url($slug).'">'.strtoupper($item['title']).'</a></li>';
				endif;
		$num++;	
		endforeach;
		$menu .= 	'</ul>';
		return $menu;
	}
	
	function menu_category()
	{
		$parent = $this->CI->Productcategory_model->get_rows('id,parent_id,title','parent_id',0)->result_array();
		$block = '';
		foreach($parent as $item){
			
			$block .= '<div class="block-cat">';
			$child = $this->CI->Productcategory_model->get_rows('id,parent_id,title','parent_id',$item['id'])->result_array();
			
			if(count($child) > 0){
				
				$block .= '<h2><a>'.strtoupper($item['title']).'</a></h2>';
				$block .= '<div class="wrap-sub">';
				foreach($child as $item2){
					$block .= '<div class="sub-cat"><a href="'.site_url(set_url_title($item2['title'])).'">'.ucfirst($item2['title']).'</a></div>';
				}
				$block .= '</div>';
				$block .= '</div>';
				
			}else{
				$block .= '<h2><a href="'.site_url(set_url_title($item['title'])).'">'.strtoupper($item['title']).'</a></h2>';
				$block .= '</div>';
			}
			
		}
		return $block;
	}
}

/* End of file Mymenu.php */ 
/* Location: ./system/application/libraries/Mymenu.php */ 